from tkinter import *
from tkinter.ttk import *

class WinGUI(Tk):
    def __init__(self):
        super().__init__()
        self.__win()
        self.tk_label_m0c6l6hz = self.__tk_label_m0c6l6hz(self)
        self.tk_input_m0c6lpcn = self.__tk_input_m0c6lpcn(self)
        self.tk_button_m0c6lvy7 = self.__tk_button_m0c6lvy7(self)
        self.tk_label_m0c6mm3a = self.__tk_label_m0c6mm3a(self)
        self.tk_input_m0c6n6vi = self.__tk_input_m0c6n6vi(self)
        self.tk_button_m0c6nb3j = self.__tk_button_m0c6nb3j(self)
        self.tk_button_m0c7djh2 = self.__tk_button_m0c7djh2(self)
        self.tk_progressbar_m0d8ueyu = self.__tk_progressbar_m0d8ueyu(self)
        self.tk_label_m0d8xhee = self.__tk_label_m0d8xhee(self)
        self.tk_label_m0dhb051 = self.__tk_label_m0dhb051(self)

    def __win(self):
        self.title("多个文件夹内的文件复制到一个文件夹中_v1.1.0")
        # 设置窗口大小、居中
        width = 572
        height = 263
        screenwidth = self.winfo_screenwidth()
        screenheight = self.winfo_screenheight()
        geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.geometry(geometry)

        self.resizable(width=False, height=False)

    def scrollbar_autohide(self, vbar, hbar, widget):
        """自动隐藏滚动条"""

        def show():
            if vbar: vbar.lift(widget)
            if hbar: hbar.lift(widget)

        def hide():
            if vbar: vbar.lower(widget)
            if hbar: hbar.lower(widget)

        hide()
        widget.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Leave>", lambda e: hide())
        if hbar: hbar.bind("<Enter>", lambda e: show())
        if hbar: hbar.bind("<Leave>", lambda e: hide())
        widget.bind("<Leave>", lambda e: hide())

    def v_scrollbar(self, vbar, widget, x, y, w, h, pw, ph):
        widget.configure(yscrollcommand=vbar.set)
        vbar.config(command=widget.yview)
        vbar.place(relx=(w + x) / pw, rely=y / ph, relheight=h / ph, anchor='ne')

    def h_scrollbar(self, hbar, widget, x, y, w, h, pw, ph):
        widget.configure(xscrollcommand=hbar.set)
        hbar.config(command=widget.xview)
        hbar.place(relx=x / pw, rely=(y + h) / ph, relwidth=w / pw, anchor='sw')

    def create_bar(self, master, widget, is_vbar, is_hbar, x, y, w, h, pw, ph):
        vbar, hbar = None, None
        if is_vbar:
            vbar = Scrollbar(master)
            self.v_scrollbar(vbar, widget, x, y, w, h, pw, ph)
        if is_hbar:
            hbar = Scrollbar(master, orient="horizontal")
            self.h_scrollbar(hbar, widget, x, y, w, h, pw, ph)
        self.scrollbar_autohide(vbar, hbar, widget)

    def __tk_label_m0c6l6hz(self, parent):
        label = Label(parent, text="需要复制的文件夹：", anchor="center", )
        label.place(x=14, y=8, width=116, height=30)
        return label

    def __tk_input_m0c6lpcn(self, parent):
        ipt = Entry(parent, )
        ipt.place(x=14, y=40, width=454, height=30)
        return ipt

    def __tk_button_m0c6lvy7(self, parent):
        btn = Button(parent, text="选择路径", takefocus=False, )
        btn.place(x=486, y=40, width=73, height=30)
        return btn

    def __tk_label_m0c6mm3a(self, parent):
        label = Label(parent, text="保存的路径：", anchor="center", )
        label.place(x=14, y=80, width=81, height=30)
        return label

    def __tk_input_m0c6n6vi(self, parent):
        ipt = Entry(parent, )
        ipt.place(x=14, y=112, width=454, height=30)
        return ipt

    def __tk_button_m0c6nb3j(self, parent):
        btn = Button(parent, text="选择路径", takefocus=False, )
        btn.place(x=485, y=112, width=73, height=30)
        return btn

    def __tk_button_m0c7djh2(self, parent):
        btn = Button(parent, text="开始复制", takefocus=False, )
        btn.place(x=302, y=178, width=224, height=71)
        return btn

    def __tk_progressbar_m0d8ueyu(self, parent):
        progressbar = Progressbar(parent, orient=HORIZONTAL, )
        progressbar.place(x=14, y=184, width=195, height=30)
        return progressbar

    def __tk_label_m0d8xhee(self, parent):
        label = Label(parent, text="复制进度：", anchor="center", )
        label.place(x=14, y=152, width=57, height=30)
        return label

    def __tk_label_m0dhb051(self, parent):
        label = Label(parent, text="", anchor="center", )
        label.place(x=14, y=221, width=219, height=30)
        return label


class Win(WinGUI):
    def __init__(self, controller):
        self.ctl = controller
        super().__init__()
        self.__event_bind()
        self.__style_config()
        self.ctl.init(self)

    def __event_bind(self):
        self.tk_button_m0c6lvy7.bind('<Button-1>', self.ctl.choosePatha)
        self.tk_button_m0c6nb3j.bind('<Button-1>', self.ctl.choosePathb)
        self.tk_button_m0c7djh2.bind('<Button-1>', self.ctl.startCopy)
        pass

    def __style_config(self):
        pass


if __name__ == "__main__":
    win = WinGUI()
    win.mainloop()